﻿using System;
using ContainerHost.ServiceModel;

namespace ContainerHost.SM
{
    class StructureMapServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactory
    {
        /// <summary>
        /// Provides an instance of the ContainerHost intialized with a StructureMap container
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="baseAddresses"></param>
        /// <returns>A ContainerServiceHost initialized with a StructureMap Container.</returns>
        protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            ContainerServiceHost serviceHost = new ContainerServiceHost(serviceType, baseAddresses);
            StructureMapContainerFacade container = new StructureMapContainerFacade();
            serviceHost.Container = container;

            return serviceHost;
        }
    }
}
